<?php
 
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('kes_biaya' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$key = isset( $_GET['key'] ) ? $_GET['key']:  "";
$av = isset( $_GET['av'] ) ? $_GET['av']:  "";

$modulname = "Kesejahteraan _BN_ Fasilitas Kesehatan _BN_ Biaya kesehatan";
 
if($_SERVER['REQUEST_METHOD'] == "POST" ){
	 
	if( $task =="edit" ){
		form_kes_biaya_submit($id );
		my_direct('index.php?com=kes_biaya');
	}elseif($task == 'upload_page'){
		form_kes_biaya_upload_submit( );
		my_direct('index.php?com=kes_biaya&task=viewupload');
	}
	
}else{ 	
	if($task == "edit"){
		$pagename = $modulname." _BN_ ".(($id ==0) ? "Tambah Data" : "Perubahan Data" );
		$view = form_kes_biaya_create($id);
	}elseif($task == 'upload'){ 
		facebox_page( 'index.php?com='.$_GET['com'].'&task=upload_page&id='.$_GET['id'], "Upload data",400);
	}elseif($task == 'upload_page'){
			my_query("TRUNCATE TABLE `kes_biaya_kesehatan_temp` ");
		$view = form_kes_biaya_upload( );
		 
		generate_my_web($view, $pagename ,"plain.php");
		exit;
	}elseif($task == 'viewupload_cancel'){
		my_query("TRUNCATE TABLE `kes_biaya_kesehatan_temp` ");
		generate_my_web("Updated", $pagename ,"plain.php");
		exit;
	}elseif($task == 'viewupload_save'){
		my_query("INSERT INTO kes_biaya_kesehatan (SELECT '',karyawan_id ,	unit_id ,	keluarga_id ,	no_pasien ,	tanggal ,	noreg ,	pos_biaya_id ,	kode_dokter ,	nama_dokter ,	total_biaya ,nama_pasien ,NOW()	 FROM kes_biaya_kesehatan_temp)");
		my_query("TRUNCATE TABLE `kes_biaya_kesehatan_temp` ");
		generate_my_web("Updated", $pagename ,"plain.php");
		exit;
	}elseif($task == 'viewupload'){  
		$view = upload_temp( );
		generate_my_web($view, $pagename ,"plain.php");
		exit;
	}elseif($task == 'delete'){ 
		delete_kesehatan_biaya($id);
		my_direct('index.php?com=kes_biaya');
	}elseif($task == "view_kes_biaya"){
		$title= "Lihat";
		facebox_page('index.php?com=kes_biaya&task=view_kes_biaya_page&id='.$id , $title , 400	); 
	}elseif($task == "view_kes_biaya_page"){ 
		$content  = view_kes_biaya($id);
		generate_my_web($content,"","plain.php");
		exit; 
	}elseif($task == "plaincetak"){
		@ob_end_clean(); 
		echo'<pre>';
		echo print_plain($key,$av);
		exit;		
	}else{
		$pagename = $modulname ; 
		load_facebox_script();
		$view =  list_biaya_kesehatan(); 
	}
}
generate_my_web($view, $pagename );
?>